<admintpl file="header" />
	<style>
		.hidden {
			display: none!important;
		}
	</style>
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="javascript:;">行家列表</a></li>
		</ul>
		<form class="well form-search">
			行家搜索：
            <input type="text" id="guest_search" style="width: 150px;" value="">

			<select id="pf_lists">
				<option value="0">请选择行家</option>
				<volist name="pf_lists" id="vo">
					<option value="{$vo.id}" class="guest">{$vo.user_nicename}</option>
				</volist>
			</select>

			<button type="button" id="add_guest">添加</button>
		</form>


		<form class="js-ajax-form" action="" method="post">
			<table class="table table-hover table-bordered table-list">
				<thead>
					<tr>
						<th width="50">排序</th>
						<th width="50">ID</th>
						<th style="text-align: center;width: 50px;">头像</th>
						<th width="150">名字</th>
						<th width="150">职位</th>
						<th width="150">公司</th>
						<th width="70">操作</th>
					</tr>
				</thead>
				<foreach name="pf_lists" item="vo">
					<if condition="$vo['advisory'] == 1">
						<tr>
							<td><input data-id="{$vo.id}" class="input input-order" type="text" size="5" value="{$vo.advisory_sort}"></td>
							<td>{$vo.id}</td>
							<td style="text-align: center"><img src="{:sp_get_user_avatar_url($vo['avatar'])}?t={:time()}" style="width: 35px;height: 35px;border: transparent;border-radius: 50%"></td>
							<td>{$vo.user_nicename}</td>
							<td>{$vo.position}</td>
							<td>{$vo.company}</td>
							<td>
								<a href="{:U('Lesson/Adminlesson/edit_lesson_pf_lists', array('id' => $vo['id'], 'op' => 'del'))}" class="js-ajax-delete">删除</a>
							</td>
						</tr>
					</if>
				</foreach>
			</table>
		</form>
	</div>
	<script src="__PUBLIC__/js/common.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/layer/layer_1.js"></script>
	<script>
        $(document).ready(function () {
            $('body').delegate('.input-order', 'change', function () {
                var order 	= $(this).val();
                var id 		= $(this).attr('data-id');
                $.get("{:U('Lesson/Adminlesson/change_pf_advisory_sort')}", {id : id, order : order}, function (data) {
                    if (data.status) {
                        window.location.reload();
                    }
                })
            });

            $('#guest_search').keyup(function (e) {
                var key = window.event ? e.keyCode : e.which;
                var val = $(this).val();

                if (key == 13) {
                    return;
				}

				$('#pf_lists option.guest').each(function () {
					var _val = $(this).text();
					if (_val.indexOf(val) < 0) {
						$(this).addClass('hidden');
					} else {
                        $(this).removeClass('hidden');
					}
                });
            });

            $('#add_guest').click(function () {
				var id = $('#pf_lists').val();
                layer.confirm('确定开通吗？', {
                    btn: ['确定', '取消']
                }, function (index) {
                    $.get("{:U('Lesson/Adminlesson/edit_lesson_pf_lists')}", {id : id, op : 'add'}, function (re) {
						if (re.status) {
							layer.msg('操作成功');
							setTimeout(function () {
								window.location.reload();
                            }, 1500);
						}
                    })
                    layer.close(index);
                });
            });
        })
	</script>
</body>
</html>